<?php
//require_once('admin_operador.php');
class Cliente extends controller//Admin_Operador
{

    function index()
    {
        $this->load->view('cliente_form');
        $this->load->library('table');
    }


    function guardar()
    {
        $this->load->model('client_model');
        if($query = $this->client_model->create_member())
        {
            //$data['main_content'] = 'cliente_successful';
            //$this->load->view('includes/template', $data);
            $this->load->view('cliente_successful');
        }
        else
        {
            $this->load->view('cliente_form');
        }
    }
    function create_member()
    {
        if ($this->input->post('guardar'))
        {

            $this->load->model('client_model');
            if($query = $this->client_model->create_member())
            {
                //$data['main_content'] = 'cliente_successful';
                //$this->load->view('includes/template', $data);
                $this->load->view('cliente_successful');
            }
            else
            {
                $this->load->view('cliente_form');
            }
        }

        if ($this->input->post('eliminar'))
        {
            $this->load->model('client_model');
            if($query = $this->client_model->eliminar())
            {
                $data['main_content'] = 'cliente_successful';
                $this->load->view('includes/template', $data);
            }
            else
            {
                $this->load->view('cliente_form');
            }
        }

        if ($this->input->post('modificar'))
        {
            $this->load->model('client_model');
            if($query = $this->client_model->modificar())
            {
                $data['main_content'] = 'cliente_successful';
                $this->load->view('includes/template', $data);
            }
            else
            {
                $this->load->view('cliente_form');
            }
        }

    }
    function busqueda_ajax()
    {
        $this->load->model('client_model');
        $id= $this->input->post('id');

        $cliente = $this->client_model->obtener($id);
//
        echo json_encode($cliente);




    }
    function imprimir()
    {
        $this->load->model('client_model');
        $clientes = $this->client_model->listar_datos_cliente();

        echo '{"aaData":';
        echo json_encode($clientes);
        echo "}";
    }
}